/**
 * 
 */
package service.impl;

import model.MMember;
import net.sf.json.JSONObject;
import service.interf.IMember;
import dao.interf.IMemberDAO;
import dao.pojo.MemberInfo;

/**
 * @author 鄢倩
 * 2013-1-16
 */
public class MemberImpl implements IMember {

	private IMemberDAO memberDao;
	
	public void setMemberDao(IMemberDAO memberDao) {
		this.memberDao = memberDao;
	}

	@Override
	public void sayHello() throws Exception {
		System.out.println("hello world");
	}

	@Override
	public String addMember(MMember model) throws Exception {
		MemberInfo member = new MemberInfo();
		member.setMemberName(model.getMemberName());
		
		memberDao.save(member);
		
		return "1";
	}
	@Override
	public String findByMemberId(Integer memberId) throws Exception {
		JSONObject jobj = new JSONObject();
		
		MemberInfo member = (MemberInfo) memberDao.findById(memberId);
		
		jobj.put("memberName", member.getMemberName());
		
		return jobj.toString();
	}

}
